
<!doctype html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta name="viewport"
          content="width=device-width, user-scalable=no, initial-scale=1.0, maximum-scale=1.0, minimum-scale=1.0">
    <meta http-equiv="X-UA-Compatible" content="ie=edge">
    <title>Document</title>
</head>
<body>
    <form action="">
        内容：<input type="text" name="text">
        <input type="submit" value="提交">
    </form>
</body>
</html>
<?php
/**
 * User: lie
 * Date: 2020/11/10 9:28
 * description: 自定义过滤字符串，使用正则匹配
 */


function strerror($str){
    $arr = array('淫', '傻');
    $res = implode($arr);
    if (preg_match("/$str/", $res)){
        echo "<script> alert('您使用了禁用词语，请重新填写'); </script>";
    } else {
        echo "内容为：".$str;
    }
}